package xiancheng.join;

/**
 * @author Mr.ma
 * @since 2022/11/1 15:35
 * join方法
 **/
public class Test07 {
    public static void main(String[] args) {
        TestRunnable02 testRunnable02 = new TestRunnable02();
        Thread thread1 = new Thread(testRunnable02);
        Thread thread2 = new Thread(testRunnable02);
        Thread thread3 = new Thread(testRunnable02);
        try {
            thread1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread1.start();
        thread2.start();
        thread3.start();
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() + " ==== " + i);
        }
    }
}
class TestRunnable02 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() + " ==== " + i);
        }
    }
}